package com.newcamping.wechat.api;

import com.newcamping.common.annotation.Log;
import com.newcamping.common.core.controller.BaseController;
import com.newcamping.common.core.domain.AjaxResult;
import com.newcamping.common.core.page.TableDataInfo;
import com.newcamping.common.enums.BusinessType;
import com.newcamping.common.utils.poi.ExcelUtil;
import com.newcamping.facilitytype.domain.FacilityType;
import com.newcamping.facilitytype.service.IFacilityTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 服务设施类型Controller
 * 
 * @author zjz
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/wechat/facilitytype")
public class WxFacilityTypeController extends BaseController
{
    @Autowired
    private IFacilityTypeService facilityTypeService;

    /**
     * 查询服务设施类型列表
     */
//    @PreAuthorize("@ss.hasPermi('facilitytype:facilitytype:list')")
    @GetMapping("/list")
    public AjaxResult list(FacilityType facilityType)
    {
        List<FacilityType> list = facilityTypeService.selectFacilityTypeList(facilityType);
        return success(list);
    }

    /**
     * 导出服务设施类型列表
     */
    @PreAuthorize("@ss.hasPermi('facilitytype:facilitytype:export')")
    @Log(title = "服务设施类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FacilityType facilityType)
    {
        List<FacilityType> list = facilityTypeService.selectFacilityTypeList(facilityType);
        ExcelUtil<FacilityType> util = new ExcelUtil<FacilityType>(FacilityType.class);
        util.exportExcel(response, list, "服务设施类型数据");
    }

    /**
     * 获取服务设施类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('facilitytype:facilitytype:query')")
    @GetMapping(value = "/{ftId}")
    public AjaxResult getInfo(@PathVariable("ftId") String ftId)
    {
        return success(facilityTypeService.selectFacilityTypeByFtId(ftId));
    }

    /**
     * 新增服务设施类型
     */
    @PreAuthorize("@ss.hasPermi('facilitytype:facilitytype:add')")
    @Log(title = "服务设施类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FacilityType facilityType)
    {
        return toAjax(facilityTypeService.insertFacilityType(facilityType));
    }

    /**
     * 修改服务设施类型
     */
    @PreAuthorize("@ss.hasPermi('facilitytype:facilitytype:edit')")
    @Log(title = "服务设施类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FacilityType facilityType)
    {
        return toAjax(facilityTypeService.updateFacilityType(facilityType));
    }

    /**
     * 删除服务设施类型
     */
    @PreAuthorize("@ss.hasPermi('facilitytype:facilitytype:remove')")
    @Log(title = "服务设施类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ftIds}")
    public AjaxResult remove(@PathVariable String[] ftIds)
    {
        return toAjax(facilityTypeService.deleteFacilityTypeByFtIds(ftIds));
    }
}
